package com.dingwei.superiordiary.mvp.presenter;

import com.dingwei.superiordiary.base.LogisticsBean;
import com.dingwei.superiordiary.base.MyBaseBean;
import com.dingwei.superiordiary.bean.FailsBean;
import com.dingwei.superiordiary.bean.LogisticsLogBean;
import com.dingwei.superiordiary.custom.myCallback;
import com.dingwei.superiordiary.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class LogisticsLogPresenter extends basePresenter {

    private Contract.LogisticsLogView logisticsView;

    public LogisticsLogPresenter(Contract.LogisticsLogView view) {
        super(view);
        this.logisticsView = view;
    }

    public void initData(String id) {
        RequestParams rp = new RequestParams(URLS.HOST+URLS.LOGISTICS_LOG);
        rp.addBodyParameter("id",id);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        x.http().post(rp, new myCallback(BaseActivity.context, LogisticsLogBean.class, rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                LogisticsLogBean bean = (LogisticsLogBean) baseBean;
                logisticsView.setData(bean);

            }

            @Override
            public void fail(FailsBean baseBean, String result) {
                logisticsView.onFail();
            }
        });
    }
}
